﻿Imports DevComponents.DotNetBar
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.DAO
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.General

Public Class frmTimKiemNhanVien
    Private m_NhanVienCtrl As New NhanVienCtrl()
    Private m_QuayGiaoDihCtrl As New QuayGiaoDichCtrl()
    Public Sub New()
        InitializeComponent()
        DataService.OpenConnection()
    End Sub

    Private Sub frmTimKiemNhanVien_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        m_QuayGiaoDihCtrl.HienThiDataGridViewComboBoxColumn(colMaQuayGD)
        m_NhanVienCtrl.HienThi(DGVNhanVien, BindingNavigatorNhanVien)
    End Sub

#Region "Tim Kiem nhan vien"
    Private Sub btnSearch_KeyDown(sender As Object, e As KeyEventArgs)
        If e.KeyCode = Keys.Enter Then
            TimKiemNhanVien()
        End If
    End Sub

    Private Sub TimKiemNhanVien()
        Try
            If cbMaNV.Checked = True Then
                m_NhanVienCtrl.TimKiemTheoMa(txtTimKiem.Text)
            ElseIf cbHoTen.Checked = True Then
                m_NhanVienCtrl.TiemKiemTheoTen(txtTimKiem.Text)
            End If
        Catch
            MessageBoxEx.Show("Không thể tìm thấy Giá trị cần tìm!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        End Try
    End Sub

    Private Sub btnSearch_Click(sender As System.Object, e As System.EventArgs) Handles btnSearch.Click
        If txtTimKiem.Text = "" Then
            MessageBoxEx.Show("Giá trị tìm rỗng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        Else
            TimKiemNhanVien()
        End If
    End Sub
#End Region

    Private Sub bindingNavigatorCloseItem_Click(sender As System.Object, e As System.EventArgs) Handles bindingNavigatorCloseItem.Click
        Me.Close()
    End Sub

    Private Sub btnHuy_Click(sender As System.Object, e As System.EventArgs) Handles btnHuy.Click
        Me.Close()
    End Sub
End Class